$import( "SmitearWebGL.Objects.Parser.Collada.DaeEntity" );
$import( "SmitearWebGL.Objects.Parser.Collada.DaeTexture" );

SmitearWebGL.Objects.Parser.Collada.DaeColorOrTexture = SmitearWebGL.Objects.Parser.Collada.DaeEntity.extend(
{
	/******** constructor ********/

	init : function( document, node )
	{
		this.type = SmitearWebGL.Objects.Parser.Collada.DaeColorOrTexture.TYPE_COLOR;
		this.color = null;
		this.texture = null;

		this._super( document, node );
		this._registClass( "SmitearWebGL.Objects.Parser.Collada.DaeColorOrTexture" );
	}
	,
	read : function( node )
	{
		this._super( node );

		var children = node.childNodes;

		for( var i = 0; i < children.length; i++ )
		{
			var child = children[i];

			switch( child.localName )
			{
				case "color":
					this.type = SmitearWebGL.Objects.Parser.Collada.DaeColorOrTexture.TYPE_COLOR;
					this.color = this.getFloats( child );
					return;

				case "texture":
					this.type = SmitearWebGL.Objects.Parser.Collada.DaeColorOrTexture.TYPE_TEXTURE;
					this.color = [1.0, 1.0, 1.0, 1.0];
					this.texture = new SmitearWebGL.Objects.Parser.Collada.DaeTexture(this.document, child);
					return;

				case "param":

					this.type = SmitearWebGL.Objects.Parser.Collada.DaeColorOrTexture.TYPE_PARAM;
					return;

				default:
					break;
			}
		}
	}
}
);

SmitearWebGL.Objects.Parser.Collada.DaeColorOrTexture.TYPE_COLOR = 0;
SmitearWebGL.Objects.Parser.Collada.DaeColorOrTexture.TYPE_TEXTURE = 1;
SmitearWebGL.Objects.Parser.Collada.DaeColorOrTexture.TYPE_PARAM = 2;